// 百米赛跑，0~10秒
const pro = new Promise((resolve, reject) => {
    const duration = Math.floor(Math.random() * 7000)  
    setTimeout(() => {
        if (Math.random() < 0.5) {
            //成功
            resolve(duration)
        } else {
            //失败
            reject('脚扭伤了')
        }

    }, duration);
})



pro.then(
    (data) => {
        console.log('on yeah! 我跑了', data / 1000, '秒');
    },
    (reason) => {
        console.log('不好意思，', reason);
    }
)